import IconMaterialSymbolsCodeBlocksOutline from '~icons/material-symbols/code-blocks-outline'

export const menuRouter = [
  {
    path: 'devtools',
    name: 'Devtools',
    meta: {
      title: '开发工具',
      icon: markRaw(IconMaterialSymbolsCodeBlocksOutline)
    },
    redirect: { name: 'RegularPage' },
    children: [
      {
        path: 'regular',
        name: 'RegularPage',
        meta: {
          title: '正则在线校验'
        },
        component: () => import('@/views/RegularPage.vue')
      }
    ]
  }
]

export const menuRouterFormat = (router, parentPath) => {
  return router.map(item => {
    item.path = parentPath ? `${parentPath}/${item.path}` : `/${item.path}`
    if (item.children && item.children.length > 0) {
      item.children = menuRouterFormat(item.children, item.path)
    }
    return Object.assign({}, item, item.meta || {})
  })
}

export const menuRouterFormatList = menuRouterFormat([...menuRouter])
